Skip to content

Conversation

@uhafner
Copy link
Member

@uhafner uhafner commented Feb 20, 2022

See #342.

The first two commits have been moved to a separate branch so that GitHub UI will not freeze during reviews anymore.

dependabot bot and others added 30 commits December 21, 2021 09:07
Bumps [database](https://github.com/jenkinsci/database-plugin) from 117.va2009e38b882 to 128.vaa83e142f7f2.
- [Release notes](https://github.com/jenkinsci/database-plugin/releases)
- [Commits](https://github.com/jenkinsci/database-plugin/commits)

---
updated-dependencies:
- dependency-name: org.jenkins-ci.plugins:database
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
dependabot bot and others added 27 commits January 24, 2022 14:16
)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@uhafner uhafner added the test A PR that adds to testing - used by Release Drafter label Feb 20, 2022

JUnitBuildSummary buildSummary = new JUnitBuildSummary(build);

assertThat(buildSummary.getTitleText()).containsAnyOf("no failures", "0 failures");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to split the title into the link and the text in the brackets and check both of them

JUnitBuildSummary buildSummary = new JUnitBuildSummary(build);

assertThat(buildSummary.getTitleText()).containsAnyOf("no failures", "0 failures");
assertThat(buildSummary.getFailureNames()).isEmpty();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the generated assertions:

Suggested change
assertThat(buildSummary.getFailureNames()).isEmpty();
assertThat(buildSummary).hasNoFailureNames();

assertThat(buildSummary.getFailureNames())
.containsExactlyInAnyOrder("JUnit.testScore[0]", "JUnit.testScore[1]", "JUnit.testScore[2]", "TestNG.testScore", "TestNG.testScore", "TestNG.testScore");
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the build summary supports navigation using links, it would be helpful to check these as well (and navigate to the detail pages)

Comment on lines +40 to +44
assertThat(buildTestResultsByClass.getTestTableEntries()).extracting(List::size).isEqualTo(2);

TestUtils.assertElementInCollection(buildTestResultsByClass.getTestTableEntries(),
testTableEntry -> testTableEntry.getTestName().equals("testAppFailNoMessage"),
testTableEntry -> testTableEntry.getTestName().equals("testAppFailNoStacktrace"));
Copy link
Member Author

@uhafner uhafner Feb 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertJ is your friend, make usage of the API:

        assertThat(buildTestResultsByClass.getTestTableEntries())
                .hasSize(2)
                .extracting(TestTableEntry::getTestName)
                .containsExactly("testAppFailNoMessage", "testAppFailNoStacktrace");

Seems that your import is wrong (in all tests!), you need to import

import static io.jenkins.plugins.analysis.junit.Assertions.*;

.openTestResultsByClass("ApplicationTest");

TestUtils.assertElementInCollection(buildTestResultsByClass.getTestTableEntries(),
tableEntry -> tableEntry.getTestName().equals("testAppFail") && tableEntry.getStatus().equals("Failed"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use AssertJ features

* @param predicates assertion criteria
* @param <E> the type of elements in this collection
*/
public static <E> void assertElementInCollection(Collection<E> collection,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work out of the box with standard AssertJ

*/
public class BuildChartEntry {

final int buildId;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fields must be private.

Comment on lines +56 to +58
WebElement mainPanel = getElement(By.cssSelector("#main-panel"));
packageLinks = TestResultsTableUtil.getLinksOfTableItems(mainPanel);
packageTableEntries = initializePackageTableEntries(mainPanel);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract duplicate code into method

Comment on lines +57 to +59
WebElement mainPanel = getElement(By.cssSelector("#main-panel"));
testLinks = TestResultsTableUtil.getLinksOfTableItems(mainPanel);
testTableEntries = initializeTestTableEntries(mainPanel);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract duplicate code into method

Comment on lines +57 to +59
WebElement mainPanel = getElement(By.cssSelector("#main-panel"));
classLinks = TestResultsTableUtil.getLinksOfTableItems(mainPanel);
classTableEntries = initializeClassTableEntries(mainPanel);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract duplicate code into method

@uhafner uhafner closed this May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test A PR that adds to testing - used by Release Drafter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants